package com.mario.nanjing.ai.config;

import com.mario.nanjing.ai.service.ChatAssistant;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.service.AiServices;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author MarioZzz
 * @create 2025-07-30 15:43
 * @Description: 知识出处 https://docs.langchain4j.dev/get-started
 */
@Configuration
public class LLMConfig {

    @Bean("chatModelQwen")
    public ChatModel chatModelQwen() {
        return OpenAiChatModel.builder()
                .apiKey(System.getenv("l4j_qwen_api"))
                .modelName("qwen-plus")
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .build();
    }

    @Bean("chatModelDeepSeek")
    public ChatModel chatModelDeepSeek() {
        return OpenAiChatModel.builder()
                .apiKey(System.getenv("l4j_deepseek_api"))
//                .modelName("deepseek-chat")
                .modelName("deepseek-reasoner")
                .baseUrl("https://api.deepseek.com/v1")
                .build();
    }

    // High-Api https://docs.langchain4j.dev/tutorials/ai-services#simplest-ai-service
    @Bean("chatAssistantDeepSeek")
    public ChatAssistant chatAssistantDeepSeek(@Qualifier("chatModelDeepSeek") ChatModel chatModelDeepSeek) {
        return AiServices.create(ChatAssistant.class, chatModelDeepSeek);
    }
}
